<?php
require_once ("View/RegisterView.php");
require_once ("Handler/UserHandler.php");
require_once ("validation.php");

class RegisterController {

	public function DoControllNewUser() {
		$Validation = new Validation();
		$Stringer = "";
		//..skapar
		$RegisterView = New RegisterView();
		$UserHandler = new UserHandler();
		
		if ($RegisterView -> TriedTocreateNewUser()) {
			if ($Validation -> ValidateUserName($RegisterView -> GetUserName())== TRUE 
			&& ($Validation -> ValidatePassword($RegisterView -> GetPassword(),$RegisterView ->GetSecondPassword())== TRUE) ) {
					
				$Stringer .= $RegisterView -> NewMemberMessage();
				$UserHandler -> DoCreateNewUser($RegisterView -> GetUserName(),$RegisterView -> GetLastName() ,$RegisterView -> GetPassword());
				$RegisterView -> ChangeAction(true);
			}

		}
		$Stringer .= $Validation->ShowErrorMessages();
		return $Stringer;
	}

}


